#include "widget.h"
#include "ui_widget.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}
/*
    geometry() 获取 QRect 类
    setGeometry() 设置控件的位置，以及尺寸
*/

void Widget::on_pushButton_up_clicked()
{
     QRect ret = ui->pushButton_target->geometry();
     qDebug() << ret;
     ui->pushButton_target->setGeometry(ret.x(), ret.y() - 20, ret.width(), ret.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect ret = ui->pushButton_target->geometry();
    qDebug() << ret;
    ui->pushButton_target->setGeometry(ret.x() + 20, ret.y(), ret.width(), ret.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect ret = ui->pushButton_target->geometry();
    qDebug() << ret;
    ui->pushButton_target->setGeometry(ret.x(), ret.y() + 20, ret.width(), ret.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect ret = ui->pushButton_target->geometry();
    qDebug() << ret;
    ui->pushButton_target->setGeometry(ret.x() - 20, ret.y(), ret.width(), ret.height());
}
